<template>
    <div class="pie">
        <div ref="myChart" style="width: 750px; height: 300px"></div>
    </div>
</template>


<script>
export default {
    data() {
        return {

        }
    },
    mounted() {
        this.setChart()
    },
    methods: {
        setChart() {
            let myChart = this.$echarts.init(this.$refs.myChart);
            let option = {
                backgroundColor: '#2c343c',

                title: {
                    text: '支付方式统计(笔数)',
                    left: 'center',
                    top: 20,
                    textStyle: {
                        color: '#ccc',
                        fontSize: '18px'
                    }
                },

                tooltip: {
                    trigger: 'item'
                },

                visualMap: {
                    show: false,
                    min: 80,
                    max: 600,
                    inRange: {
                        colorLightness: [0, 1]
                    }
                },
                series: [
                    {
                        name: '支付方式',
                        type: 'pie',
                        radius: '60%',
                        center: ['50%', '50%'],
                        data: [
                            {value: 335, name: 'POS通'},
                            {value: 310, name: '支付宝'},
                            {value: 274, name: '微信支付'},
                            {value: 235, name: '会员'},
                            {value: 400, name: '银商二维码'}
                        ].sort(function (a, b) { return a.value - b.value; }),
                        roseType: 'radius',
                        label: {
                            color: 'rgba(255, 255, 255, 0.3)'
                        },
                        labelLine: {
                            lineStyle: {
                                color: 'rgba(255, 255, 255, 0.3)'
                            },
                            smooth: 0.2,
                            length: 10,
                            length2: 20
                        },
                        itemStyle: {
                            color: '#c23531',
                            shadowBlur: 200,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        },

                        animationType: 'scale',
                        animationEasing: 'elasticOut',
                        animationDelay: function (idx) {
                            return Math.random() * 200;
                        }
                    }
                ],
            };
             myChart.setOption(option)
        }
    }
}
</script>